
package advice.around;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

import com.e885.log.E885Logger;

/**
 * 如果我們要記錄 log，需在 target 執行之前和執行之後，那麼就要二個 advice(LogBeforeAdvice and AfterAdvice), 在這個例子, 我們可以解決要 implement 二個 Advice, 一個是
 * BeforeAdvice(LogBeforeAdvice), 一個是 AfterAdvice(LogAfterAdvice)
 * 
 * @author Eric.Kao(gau168.gau@msa.hinet.net)
 * @version 1.0
 * @company E885 Group
 * @copyright Copyright (c) 2001-2008
 */

public class LogInterceptor implements MethodInterceptor
{

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.aopalliance.intercept.MethodInterceptor#invoke(org.aopalliance.intercept.MethodInvocation)
	 */
	public Object invoke( MethodInvocation invocation ) throws Throwable
	{
		E885Logger.testLog.debug( "Before Advice 會在目標物件的方法執行之前被呼叫" );

		try
		{
			return invocation.proceed();
		}
		finally
		{
			E885Logger.testLog.debug( "LogAfterAdvice 會在目標物件的方法執行之後被呼叫" );
		}
	}
}
